package com.ruoyi.project.system.style.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.style.domain.BizHouseStyle;
import com.ruoyi.project.system.style.service.IBizHouseStyleService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 家装风格Controller
 * 
 * @author ruoyi
 * @date 2020-05-01
 */
@Controller
@RequestMapping("/system/style")
public class BizHouseStyleController extends BaseController
{
    private String prefix = "system/style";

    @Autowired
    private IBizHouseStyleService bizHouseStyleService;

    @RequiresPermissions("system:style:view")
    @GetMapping()
    public String style()
    {
        return prefix + "/style";
    }

    /**
     * 查询家装风格列表
     */
    @RequiresPermissions("system:style:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BizHouseStyle bizHouseStyle)
    {
        startPage();
        List<BizHouseStyle> list = bizHouseStyleService.selectBizHouseStyleList(bizHouseStyle);
        return getDataTable(list);
    }

    /**
     * 导出家装风格列表
     */
    @RequiresPermissions("system:style:export")
    @Log(title = "家装风格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BizHouseStyle bizHouseStyle)
    {
        List<BizHouseStyle> list = bizHouseStyleService.selectBizHouseStyleList(bizHouseStyle);
        ExcelUtil<BizHouseStyle> util = new ExcelUtil<BizHouseStyle>(BizHouseStyle.class);
        return util.exportExcel(list, "style");
    }

    /**
     * 新增家装风格
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存家装风格
     */
    @RequiresPermissions("system:style:add")
    @Log(title = "家装风格", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BizHouseStyle bizHouseStyle)
    {
        return toAjax(bizHouseStyleService.insertBizHouseStyle(bizHouseStyle));
    }

    /**
     * 修改家装风格
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        BizHouseStyle bizHouseStyle = bizHouseStyleService.selectBizHouseStyleById(id);
        mmap.put("bizHouseStyle", bizHouseStyle);
        return prefix + "/edit";
    }

    /**
     * 修改保存家装风格
     */
    @RequiresPermissions("system:style:edit")
    @Log(title = "家装风格", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BizHouseStyle bizHouseStyle)
    {
        return toAjax(bizHouseStyleService.updateBizHouseStyle(bizHouseStyle));
    }

    /**
     * 删除家装风格
     */
    @RequiresPermissions("system:style:remove")
    @Log(title = "家装风格", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bizHouseStyleService.deleteBizHouseStyleByIds(ids));
    }
}
